//
//  VipSelectCell.m
//  Shengzhuli
//
//  Created by FXGuo on 2017/7/26.
//  Copyright © 2017年 kamangkeji. All rights reserved.
//

#import "VipSelectCell.h"
#import "VipSelevtButton.h"

@interface VipSelectCell ()

@property (weak, nonatomic) IBOutlet VipSelevtButton *experienceBtn;
@property (weak, nonatomic) IBOutlet VipSelevtButton *addBtn;
@property (nonatomic,strong) VipSelevtButton *lastSelectBtn;

@end

@implementation VipSelectCell

- (void)awakeFromNib {
    [super awakeFromNib];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        self.experienceBtn.layer.borderWidth = 1;
        self.experienceBtn.layer.borderColor = RGBColorOne(51).CGColor;
        self.addBtn.layer.borderWidth = 1;
        self.addBtn.layer.borderColor = RGBColorOne(51).CGColor;
    });
    self.experienceBtn.selected = YES;
    self.lastSelectBtn = self.experienceBtn;
}
- (void)setModel:(AdderMoneyModel *)model
{
    _model = model;
    self.addBtn.subTitle = [NSString stringWithFormat:@"剩余名额:%zd位",model.residueMember];
}
- (IBAction)vipSelectClick:(VipSelevtButton *)btn
{
    if (btn == self.lastSelectBtn) return;
    btn.selected = !btn.selected;
    self.lastSelectBtn.selected = NO;
    self.lastSelectBtn = btn;
    if (self.selectBlock) {
        self.selectBlock(btn.tag);
    }
}
 - (void)setType:(NSInteger)type
{
    _type = type;
    if (self.type == 2) {
        self.addBtn.selected = YES;
        self.experienceBtn.selected = NO;
        self.lastSelectBtn = self.addBtn;
    }else {
        self.addBtn.selected = NO;
        self.experienceBtn.selected = YES;
        self.lastSelectBtn = self.experienceBtn;
    }
}



@end
